﻿/* CMakeProject_test.cpp
* This is a test code to stdut c++
* test by leiyinghaonan
*/

#include "CMake_test.h"
using namespace std;

namespace LSPACE
{
	int LBASIC::test_while() {
		int sum = 0, val = 1;
		while (val <= 3) {
			sum += val; //sum = sum + val;
			++val; // val = val + 1
			cout << "while val = " << val << endl;
		}
		cout << "while sum = " << sum << endl;
		cout << "====================" << endl;
		return  0;
	}

	int LBASIC::test_for() {
		int sum = 0, val = 1;
		for (int val = 1; val <= 3; ++val) {
			sum += val;
			cout << "for val = " << val << endl;
		}
		cout << "for sum = " << sum << endl;
		cout << "====================" << endl;
		for (int i = 0, j = -1; i <= 4, j >= -5; i++, j--) {
			cout << "i=" << i << ",j=" << j << endl;
		}
		cout << "====================" << endl;
		return 0;
	}

	int LBASIC::test_array() {
		int  arr[3][4] = {
			{0,1,2,3},
			{4,5,6,7},
			{8,9,10,11}
		};
		return 0;
	}

	int LBASIC::test_if() {
		int sum = 0, val = 1;
		for (int val = 1; val <= 8; val++) {
			if (val <= 2)
				cout << "vak <=2" << endl;
			else if (val < 4 && val>2)
				cout << "val >2 and val <4" << endl;
			else if (val >= 6 || val == 5) {
				cout << "val >=6 or val ==5" << endl;
			}
			cout << "for if val = " << val << endl;
		}
		cout << "====================" << endl;

		return 0;
	}

	int LBASIC::test_xx() {

		int a = 10;
		cout << "a = " << a << endl;
		cout << "2*a++ =" << 2 * a++ << endl;
		cout << "a = " << a << endl;
		cout << "2*++a =" << 2 * ++a << endl;
		cout << "a = " << a << endl;

		cout << "====================" << endl;
		return 0;
	}

}